<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateDealerVehicleSeriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('dealer_vehicle_series', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('dealer_id')->unsigned()->comment('经销商ID');
            $table->foreign('dealer_id')->references('id')->on('dealers')->onDelete('cascade');
            $table->unsignedBigInteger('vehicle_series_id')->comment('系列ID');
            $table->foreign('vehicle_series_id')->references('id')->on('vehicle_series')->onDelete('cascade');
            $table->timestamps();
        });

        Schema::table('vehicles', function (Blueprint $table) {
            $table->string('code',20)->nullable()->comment('车型编号')->change();

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('dealer_vehicle_series');
    }
}
